/**
 * 
 */
package org.swing.utility.jai.component;

import java.awt.Component;
import java.awt.image.RenderedImage;

import javax.media.jai.RenderedOp;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;

/**
 * @author lqnhu
 *
 */
public class ImageTreeRenderer extends DefaultTreeCellRenderer {
	@Override
	public Component getTreeCellRendererComponent(JTree tree, Object value,
			boolean selected, boolean expanded, boolean leaf, int row,
			boolean hasFocus) {
		super.getTreeCellRendererComponent(tree, value, selected, expanded,
				leaf, row, hasFocus);
		RenderedImage ri = (RenderedImage) value;
		if (ri instanceof RenderedOp) {
			RenderedOp op = (RenderedOp) ri;
			setText("<html><body><b>RenderedOp:</b> <i>"
					+ op.getOperationName() + "</i></body></html>");
		} else {
			setText(ri.getClass().getSimpleName());
		}
		return this;
	}
}
